﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfService
{
    using Microsoft.SharePoint.Client.Services;
    using System.ServiceModel.Activation;
    using Microsoft.SharePoint;

    [BasicHttpBindingServiceMetadataExchangeEndpointAttribute]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class RevertService : IRevert
    {
        public void Revert(string listName, int listItemId)
        {
            SPList oList = SPContext.Current.Web.Lists[listName];

            SPListItem oItem = oList.GetItemById(listItemId);

            if (oItem.Versions.Count > 1)
            {
                oItem.Versions.Restore(1);
            }
        }
    }
}
